package test.spring;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.yuqih.common.spring.StaticContextContainer;

/**
 * 该类和SpringBeanUtil的区别为该类的成员及方法均为非静态的，所以如果多个项目公用该jar包时，应该使用此类
 * 
 * @author yuqih
 * @see StaticContextContainer
 * 
 */
public class ContextContainer implements ApplicationContextAware {
	private Log log = LogFactory.getLog(getClass());

	private ApplicationContext context;

	@Override
	public void setApplicationContext(ApplicationContext context)
			throws BeansException {
		this.context = context;
		log.debug("ApplicationContext registed");
	}

	/**
	 * @return the context
	 */
	public ApplicationContext getContext() {
		return context;
	}

	public BeanFactory getBeanFactory() {
		return context;
	}

}
